NB IoT
api.nbSend(addr, port, msg, timeout, type)
- Overview
- Arguments
- Example
Sends buffer msg to NB on specified IP, port and protocol type. Maximum length of Rx and Tx messages is 512 Bytes. Maximum execution time is limited by timeout milliseconds.
- addr (string) - IP address
- port (integer) - Port
- msg (string) - String to be sent to NB
- timeout (integer) - The maximum execution time in milliseconds
- type (string) - Protocol type, either UDP or TCP.
-- sends "test message" string to IP 185.8.239.192 on port 5566 with 6s timeout
status,answer = api.nbSend("185.8.239.192", 5566, "test message", 6000, "UDP")
api.nbAT(command, timeout, wakeUp)
- Overview
- Arguments
- Return
- Example #1
- Example #2
- Example #3
Sends an AT command to NB module with specified timeout.
Print of AT command can be turned ON and OFF by using this command:
-- AT_DEBUG_OFF - turn off
-- AT_DEBUG_ON - turn on
api.nbAT("AT_DEBUG_ON")
- command (string) - AT command
- timeout (integer) - The maximum execution time in milliseconds
- wakeUp (integer, optional) - Sending 1 will make sure that module is not asleep
- answer (string) - Nil or non-zero length string with an answer to a AT command
- status (integer) - Zero for success, negative for failure
-- Get IMSI number of SIM card with timeout of 4 seconds
res = api.nbAT("AT+CIMI", 4000)
print(res)
-- IMEI --
x=api.nbAT("AT+CGSN")
start = string.find(x, "\n")
finish = string.find(x, "\r", start+1)
imei = string.sub(x,(start+1),(finish-1))
print("IMEI: " .. imei)
-- Get signal strength
res,b = api.nbAT("AT+CSQ")
print(res)